<html>
<head>
	<title>文件上传页面</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css"/>
	<script type="text/javascript" src="ExtJS/ext-all.js" ></script>
	<script type="text/javascript">
	 Ext.onReady(function(){
		var VP = new Ext.Viewport({
			id:'mainview',
			layout:	'border',
			renderTo: Ext.getBody()
			});
		 var msg = function(title, msg) {
			 Ext.Msg.show({
				 title: title,
				 msg: msg,
				 minWidth: 200,
				 modal: true,
				 icon: Ext.Msg.INFO,
				 buttons: Ext.Msg.OK
			 });
		 };
		 var form = new Ext.form.FormPanel({
			 frame: true,
			 title: '表单标题',
			 style: 'margin:10px',
			 fileUpload: true,
			 width: 500,
			 frame: true,
			 title: '图片上传操作',
			 autoHeight: true,
			 bodyStyle: 'padding: 10px 10px 0 10px;',
			 labelWidth: 50,
			 defaults: {
				 anchor: '95%',
				 allowBlank: false,
				 msgTarget: 'side'
			 },
			 items: [{
				 xtype: 'textfield',
				 fieldLabel: '名称',
				 name:"filename"
			 }, {
				 xtype: 'fileuploadfield',
				 id: 'form-file',
				 emptyText: '选择文件',
				 fieldLabel: '文件',
				 name: 'filepath',
				 buttonText: '选择',
				 regex : /\.(jpg|jpeg|gif|GIF|png|PNG)$/,
				 buttonCfg: {
					 iconCls: 'upload-icon'
				 }
			 },{
                 xtype: "textarea",
                 fieldLabel: "备注",
                 id: "memo",
                 name: 'description',
                 labelSepartor: "：",
                 width: 250
             }],
			 buttons: [{
				 text: '上传',
				 handler: function() {
					 if (form.getForm().isValid()) {
						 form.getForm().submit({
							 url: '/upload/uploadfile',//后台处理的页面
							 waitMsg: '正在上传...',
							 success: function(form, action) {
								 window.location = "/upload/list";
							 }
						 });
					 }
				 }
			 }, {
				 text: '重置',
				 handler: function() {
					 form.getForm().reset();
				 }
			 }]
		 });
		 var win = new Ext.Window({
			 title: '窗口',
			 width: 540,
			 height: 374,
			 resizable: true,
			 modal: true,
			 closable: true,
			 maximizable: true,
			 minimizable: true,
			 items: form
		 });
		 win.show();
		});
	</script>
</head>
<body>
</body>
</html>